﻿<%@ Page Language="vb" AutoEventWireup="false" CodeBehind="EditContact.aspx.vb" Inherits="WebPhonebook.EditContact" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
    
        Welcome to the Edit Contact Page<br />
        <br />
        The old contact is:<asp:ListView ID="ListView1" runat="server" 
            DataSourceID="SqlDataSource1">
            <AlternatingItemTemplate>
                <span style="background-color: #FAFAD2;color: #284775;">fname:
                <asp:Label ID="fnameLabel" runat="server" Text='<%# Eval("fname") %>' />
                <br />
                lname:
                <asp:Label ID="lnameLabel" runat="server" Text='<%# Eval("lname") %>' />
                <br />
                cell:
                <asp:Label ID="cellLabel" runat="server" Text='<%# Eval("cell") %>' />
                <br />
<br /></span>
            </AlternatingItemTemplate>
            <EditItemTemplate>
                <span style="background-color: #FFCC66;color: #000080;">fname:
                <asp:TextBox ID="fnameTextBox" runat="server" Text='<%# Bind("fname") %>' />
                <br />
                lname:
                <asp:TextBox ID="lnameTextBox" runat="server" Text='<%# Bind("lname") %>' />
                <br />
                cell:
                <asp:TextBox ID="cellTextBox" runat="server" Text='<%# Bind("cell") %>' />
                <br />
                <asp:Button ID="UpdateButton" runat="server" CommandName="Update" 
                    Text="Update" />
                <asp:Button ID="CancelButton" runat="server" CommandName="Cancel" 
                    Text="Cancel" />
                <br /><br /></span>
            </EditItemTemplate>
            <EmptyDataTemplate>
                <span>No data was returned.</span>
            </EmptyDataTemplate>
            <InsertItemTemplate>
                <span style="">fname:
                <asp:TextBox ID="fnameTextBox" runat="server" Text='<%# Bind("fname") %>' />
                <br />lname:
                <asp:TextBox ID="lnameTextBox" runat="server" Text='<%# Bind("lname") %>' />
                <br />cell:
                <asp:TextBox ID="cellTextBox" runat="server" Text='<%# Bind("cell") %>' />
                <br />
                <asp:Button ID="InsertButton" runat="server" CommandName="Insert" 
                    Text="Insert" />
                <asp:Button ID="CancelButton" runat="server" CommandName="Cancel" 
                    Text="Clear" />
                <br /><br /></span>
            </InsertItemTemplate>
            <ItemTemplate>
                <span style="background-color: #FFFBD6;color: #333333;">fname:
                <asp:Label ID="fnameLabel" runat="server" Text='<%# Eval("fname") %>' />
                <br />
                lname:
                <asp:Label ID="lnameLabel" runat="server" Text='<%# Eval("lname") %>' />
                <br />
                cell:
                <asp:Label ID="cellLabel" runat="server" Text='<%# Eval("cell") %>' />
                <br />
<br /></span>
            </ItemTemplate>
            <LayoutTemplate>
                <div ID="itemPlaceholderContainer" runat="server" 
                    style="font-family: Verdana, Arial, Helvetica, sans-serif;">
                    <span runat="server" id="itemPlaceholder" />
                </div>
                <div style="text-align: center;background-color: #FFCC66;font-family: Verdana, Arial, Helvetica, sans-serif;color: #333333;">
                </div>
            </LayoutTemplate>
            <SelectedItemTemplate>
                <span style="background-color: #FFCC66;font-weight: bold;color: #000080;">fname:
                <asp:Label ID="fnameLabel" runat="server" Text='<%# Eval("fname") %>' />
                <br />
                lname:
                <asp:Label ID="lnameLabel" runat="server" Text='<%# Eval("lname") %>' />
                <br />
                cell:
                <asp:Label ID="cellLabel" runat="server" Text='<%# Eval("cell") %>' />
                <br />
<br /></span>
            </SelectedItemTemplate>
        </asp:ListView>
        <asp:SqlDataSource ID="SqlDataSource1" runat="server" 
            ConnectionString="<%$ ConnectionStrings:PhonebookConnectionString3 %>" 
            SelectCommand="SELECT * FROM [contacts] WHERE ([cell] = @cell)">
            <SelectParameters>
                <asp:SessionParameter Name="cell" SessionField="cell" Type="String" />
            </SelectParameters>
        </asp:SqlDataSource>
        <br />
        Update the Contact<br />
        <br />
        First Name<br />
        <asp:TextBox ID="Fname" runat="server"></asp:TextBox>
        <br />
        <br />
        Last Name<br />
        <asp:TextBox ID="Lname" runat="server"></asp:TextBox>
        <br />
        <br />
        Cell Number<br />
        <asp:TextBox ID="Cell" runat="server"></asp:TextBox>
        <asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server" 
            ControlToValidate="cell" ErrorMessage="Phone Number Must be: xxx-xxx-xxxx" 
            ForeColor="Red" ValidationExpression="((\(\d{3}\) ?)|(\d{3}-))?\d{3}-\d{4}"></asp:RegularExpressionValidator>
        <br />
        <asp:Button ID="Button1" runat="server" Text="Update" />
        <br />
        <br />
        <asp:Label ID="Message" runat="server"></asp:Label>
    
    </div>
    </form>
</body>
</html>
